<%-- 
    Document   : Calculadora
    Created on : 24/05/2012, 09:01:37 PM
    Author     : mtejadaj
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%! 
    String Option;
    String Result;
    Double Op2;
    Double Op1;
%>
<%
    Option = request.getParameter("Opt");
    Op1 = Double.parseDouble(request.getParameter("Oper1"));
    Op2 = Double.parseDouble(request.getParameter("Oper2"));

    if(Option.equals("1"))
    {
        Result = Double.toString(Op1 + Op2);
    }
    else
        if(Option.equals("2"))
        {
            Result = Double.toString(Op1 - Op2);
        }
        else
            if(Option.equals("3"))
            {
                Result = Double.toString(Op1 * Op2);
            }
            else
                if(Option.equals("4"))
                {
                    if(!(Op2.equals(0.0)))
                    {
                        Result = Double.toString(Op1 / Op2);
                    }
                    else
                    {
                        Result = "Error";
                    }
                }
    
%>
        
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Calculadora</title>
    </head>
    <body>
        <h1>Calculadora</h1><BR>
        <p>El resultado es: <%=Result%></p>
    </body>
</html>
